home *** CD-ROM | disk | FTP | other *** search
/ PC User 2003 January / Disc 3 / Amethyst.iso / live / usr / libexec / kernel / grub-del.pl next >
Encoding:
Perl Script  |  2002-11-11  |  695 b   |  32 lines

  1. #!/usr/bin/perl
  2. # $Id: grub-del.pl,v 1.1 1999/08/30 15:08:23 duwe Exp $
  3.  
  4. $delimage = "\Q$ARGV[0]";
  5.  
  6. open (BGML, "</boot/grub/menu.lst") || die;
  7.  
  8. $elc = "";
  9.  
  10. $i = 0;
  11.  
  12. # read /boot/grub/menu.lst line by line, assembling it into "entries"
  13. while (<BGML>) {
  14.   m/^\s*title\s*=/ && $i++; # advance to a new entry
  15.   $elc[$i] .= $_;
  16. }
  17. close BGML;
  18.  
  19. $secret = "no";
  20.  
  21. # Now write out all entries but the ones that reference the named kernel.
  22. while (@elc) {
  23.   if ($elc[0] !~
  24.       m,^\s*kernel\s*=\s*/boot/vmlinuz(?:-pc97)?-$delimage-modular\s,sm) {
  25.     print $elc[0];
  26.     ($elc[0] =~ m,^\s*password\s*=,sim) && ($secret = "yes");
  27.   }
  28.   shift @elc;
  29. }
  30.  
  31. chmod 0600, "/proc/self/fd/1" unless ($secret eq "no");
  32.